#include "../../common/rabbitmq.hpp"
#include <thread>
#include <gflags/gflags.h>


DEFINE_bool(run_mode, false, "程序的运行模式, false-调试模式, true-发布模式");
DEFINE_string(log_file, "", "发布模式下, 用于指定日志文件的路径");
DEFINE_int32(log_level, 0, "发布模式下, 用于指定日志的输出等级");

DEFINE_string(user, "root", "这是rabbitmq访问用户名");
DEFINE_string(pswd, "ok", "rabbitmq访问密码");
DEFINE_string(host, "127.0.0.1:5672", "这是rabbitmq的服务器地址信息");

void callback(const char* body, size_t sz)
{
    std::string message;
    message.assign(body, sz);
    std::cout << "收到消息: " << message << std::endl;
}

int main(int argc, char* argv[])
{
    google::ParseCommandLineFlags(&argc, &argv, false);
    Init_logger(FLAGS_run_mode, FLAGS_log_file, FLAGS_log_level);

    MQClient client(FLAGS_user, FLAGS_pswd, FLAGS_host);

    client.declareComponents("test_exchange", "test_queue");
    client.consume("test_queue", callback);

    std::this_thread::sleep_for(std::chrono::seconds(60));

    return 0;
}